﻿using CTM.Web.Models.View.Conversation;
using CTM.Web.Models.View.Feedback;
using CTM.Web.Models.View.Notification;
using CTM.Web.Utils;
using System;
using System.Collections.Generic;
using System.Linq;

namespace CTM.Web.Models.View.Home
{
    public class HomeViewModel
    {
        #region Properties

        /// <summary>
        /// The current viewing user
        /// </summary>
        public string Id { get; set; }

        /// <summary>
        /// The current viewing year
        /// </summary>
        public int Year { get; set; }

        /// <summary>
        /// Status collection (positive, neutral, negative)
        /// </summary>
        public IEnumerable<Emoticon> Statuses { get; set; }

        /// <summary>
        /// Conversation type collection (goal, career, individual)
        /// </summary>
        public IEnumerable<PostType> ConversationTypes { get; set; }

        /// <summary>
        /// Conversation collection
        /// </summary>
        public IEnumerable<ConversationViewModel> Conversations { get; set; }

        public Dictionary<Emoticon, int> StatusSummaries { get; set; }

        public Dictionary<PostType, int> ClassificationSummaries { get; set; }

        public bool GivenToMe { get; private set; }
        public bool GivenByMe { get; private set; }

        /// <summary>
        /// Feedback collection
        /// </summary>
        public IEnumerable<FeedbackViewModel> Feedbacks { get; set; }

        public Dictionary<Emoticon, int> FeedbackSummaries { get; set; }

        /// <summary>
        /// Notification collection
        /// </summary>
        public IEnumerable<NotificationViewModel> Notifications { get; set; }

        #endregion

        public HomeViewModel()
        {
            Year = DateTime.Today.Year;

            // Get all emoticons
            Statuses = Enum.GetValues(typeof(Emoticon)).Cast<Emoticon>();

            // Get all conversation types
            ConversationTypes = Enum.GetValues(typeof(PostType)).Cast<PostType>();

            // Get all feedback types
            GivenToMe = true;
            GivenByMe = true;

            Conversations = Enumerable.Empty<ConversationViewModel>();
            StatusSummaries = new Dictionary<Emoticon, int>();
            ClassificationSummaries = new Dictionary<PostType, int>();

            Feedbacks = Enumerable.Empty<FeedbackViewModel>();
            FeedbackSummaries = new Dictionary<Emoticon, int>();

            Notifications = Enumerable.Empty<NotificationViewModel>();
        }
    }

    public class HomeSearchModel
    {
        public int Year { get; set; }

        public HomeSearchModel()
        {
            Year = DateTime.Today.Year;
        }
    }

    public class HomeConversationSearchModel
    {
        public int? Year { get; set; }
        public List<Emoticon> Statuses { get; set; }
        public List<PostType> Types { get; set; }
        public string Keyword { get; set; }

        public HomeConversationSearchModel()
        {
            Statuses = new List<Emoticon>();
            Types = new List<PostType>();
        }
    }    
}